//
//  LRXThingView.m
//  路人侠
//
//  Created by zhangxulong on 2/9/16.
//  Copyright © 2016 zhangxulong. All rights reserved.
//

#import "LRXThingView.h"
@interface LRXThingView()
@end
@implementation LRXThingView

- (instancetype)layoutThingSubviews:(LRXThing *)thing
{
    
    LRXThingView * view = [[LRXThingView alloc]init];
    //物品的标签
    UIButton * thingLabel = [UIButton buttonWithType:UIButtonTypeCustom];
    NSString * BtnTitle = [[NSString alloc]init];
    [thingLabel setTitleColor:[UIColor colorWithRed:33 green:33 blue:33] forState:UIControlStateNormal];
    thingLabel.titleLabel.font = [UIFont systemFontOfSize:28 * hScale];
    //判断是否是多件物品
    if (![thing.thingCount isEqualToString:@"1"]) {
        BtnTitle = [NSString stringWithFormat:@"%@X%@",thing.thingName,thing.thingCount];
    
        
    }else{
        
        
        BtnTitle = [NSString stringWithFormat:@"%@",thing.thingName];
    
    }
    
    [thingLabel setTitle:BtnTitle forState:UIControlStateNormal];
    

    //thingLabel 的自适应大小
    [thingLabel sizeToFit];

    //将thingLabel的宽度传入变量方便Controller布局
    self.thingWidth = thingLabel.frame.size.width;

    //thingLabel的位置
    thingLabel.frame = CGRectMake(20 * wScale, 12 *hScale, self.thingWidth, 30 * hScale);
    
    [self addSubview:thingLabel];
    
    return view;
}
@end
